package processor;

import org.apache.http.HttpHost;
import selenium.WeiBoWebSelenium;
import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.Spider;
import us.codecraft.webmagic.processor.PageProcessor;

/**
 * Created by zhangcheng on 2017/4/24 0024.
 */
public class WeiboWapPageProcessor implements PageProcessor {
    private Site site = Site.me()
            .setRetryTimes(3)
            .setUserAgent("Mozilla/5.0 (Linux; U; Android 2.3.6; en-us; Nexus S Build/GRK39F) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1")
            .setHttpProxy(new HttpHost("10.101.1.6",80))
            .setSleepTime(1000);

    public void process(Page page) {
        System.out.println("pageinfo:");
        System.out.println(page.getHtml());
    }

    public WeiboWapPageProcessor() throws Exception {
        this.site = WeiBoWebSelenium.click(this.site, "18007303287", "qwertsekfo1");
        System.out.println(site);
    }

    public Site getSite() {
        return site;
    }

    public static void main(String[] args) throws Exception {
        Spider.create(new WeiboWapPageProcessor()).addUrl("http://weibo.cn/").run();
    }
}
